import base from './base'; // 导入接口域名列表
import axios from './http'; // 导入http中创建的axios实例
const apiUrl = base.test;
// 导出接口
export default {
  // 新增银行卡
  addBankCard (params) {
    return axios.post(`${apiUrl}/nu/client/bank/card/`, params);
  },

  // 删除用户银行卡 nu/client/bank/card/{id}
  delBankCard (id) {
    return axios.get(`${apiUrl}/nu/client/bank/card/${id}`);
  },

  // 获取用户银行卡列表 
  getBankList () {
    return axios.get(`${apiUrl}/nu/client/bank/card/list`);
  },

  // /nu/anon/user/oauth2/authorize
  getOauthAddress(params) {
    return axios.post(`${apiUrl}/nu/anon/user/oauth2/authorize`, params);
  },
  // /nu/anon/user/oauth2/access
  getOauthToken(params) {
    return axios.post(`${apiUrl}/nu/anon/user/oauth2/access`, params);
  },
  // 登录 
  userLogin(params) {
    return axios.post(`${apiUrl}/nu/client/user/customer/bind`, params);
  },
  // 用户注册（临时）
  register(params) {
    return axios.post(`${apiUrl}/nu/anon/signUp`, params);   
  },
  // 请求短信验证码
  requestCode(params) {
    const {phoneNumber, type} = params;
    return axios.get(`${apiUrl}/nu/anon/login/sendCode?type=${type}&phoneNumber=${phoneNumber}`, params); 
  },
  // 忘记密码 重置密码
  updatePassword(params) {
    return axios.post(`${apiUrl}/nu/anon/updatePassword`, params);   
  },
  // 获取用户基本信息和代理级别 
  getUserInfo () {
    return axios.get(`${apiUrl}/nu/client/user/customer/info`);
  },
  // 获取用户基本信息和代理级别 分享专用
  getUserInfo1(userId) {
    return axios.get(`${apiUrl}/nu/member/info/${userId}`);
  },
  // 修改绑定的手机号 
  updatePhoneNumber(params) {
    return axios.post(`${apiUrl}/nu/client/user/customer/updatePhoneNumber`, params);   
  }
  
}

function getShareCode (id) {
  return axios.get(`${apiUrl}/nu/client/user/customer/generateRegisterUrl?agencyId=${id}`)
}
function getMemberInfo() {
  return axios.get(`${apiUrl}/nu/client/member/info`);
}
// 下单之前获取用户信息
function getMemberInfo1() {
  return axios.get(`${apiUrl}/nu/client/member/level/info`);
}
function getMemberReward() {
  return axios.get(`${apiUrl}/nu/client/member/bonus`);
}
function updateMemberLevel(param) {
  return axios.post(`${apiUrl}/nu/client/member/improve/${param.userId}/${param.agencyId}`);
}
function getMyMember(pageNo, pageSize) {
  return axios.get(`${apiUrl}/nu/client/member/members/list?currentPage=${pageNo}&pageSize=${pageSize}`);
}
function editPassword(param) {
  return axios.post(`${apiUrl}/nu/client/user/customer/updatePassword`, param);
}
// 获取代理等级列表
function agencyList() {
  return axios.get(`${apiUrl}/nu/agency/level/list`);
}
// 获取父级信息 nu/client/member/level/info/
function getFatherInfo(fatheraUserId) {
  return axios.get(`${apiUrl}/nu/client/member/level/info/${fatheraUserId}`);
}

export {
  getMemberInfo, editPassword, getMemberReward, updateMemberLevel,
  getMyMember, agencyList, getFatherInfo,getMemberInfo1, getShareCode
}